package com.business_clean.ui.adapter.group;

import android.view.View;

import com.business_clean.R;
import com.business_clean.data.mode.group.GroupMangerListEntity;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;

import org.jetbrains.annotations.NotNull;

public class GroupMangerAdapter extends BaseQuickAdapter<GroupMangerListEntity, BaseViewHolder> {

    private boolean isSelected = false;//代表是否有选中的状态

    public GroupMangerAdapter(boolean isSelected) {
        super(R.layout.item_group_manager);
        this.isSelected = isSelected;
        addChildClickViewIds(R.id.iv_item_group_edit, R.id.iv_item_group_del);
    }

    @Override
    protected void convert(@NotNull BaseViewHolder holder, GroupMangerListEntity item) {
        holder.setText(R.id.tv_item_group_title, item.getGroup_name())
                .setText(R.id.tv_item_group_date, item.getWork_day_desc())
                .setText(R.id.tv_item_group_date_k, item.getIn_class_desc())
                .setText(R.id.tv_item_group_attendance, item.getAttendance_method_name());
        if (item.getAddress_list() != null && item.getAddress_list().size() > 0) {
            holder.setText(R.id.tv_item_group_address, String.join(",", item.getAddress_list()));
        } else {
            holder.setText(R.id.tv_item_group_address, "不限制");
        }

        holder.getView(R.id.iv_item_group_edit).setVisibility(isSelected ? View.GONE : View.VISIBLE);
        holder.getView(R.id.iv_item_group_del).setVisibility(isSelected ? View.GONE : View.VISIBLE);

    }


}
